<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
      window.onload =function (){
        //演示将json->string
        var jsonPerson={
          "name":"jack",
          "age":20
        }
        //stringify并不会影响原来的json对象，只是返回一个string对象
        console.log("jsonPerson ",jsonPerson)//json类型
        var strPerson = JSON.stringify(jsonPerson);
        console.log("strPerson ",strPerson,"strPerson类型 ",typeof strPerson)

        //string -> json
        //parse也不会改变string对象，只是返回json类型
        var strDog="{\"name\":\"小黄狗\",\"age\":3}"
        var jsonDog = JSON.parse(strDog);
        console.log("jsonDog= ",jsonDog)
      }
    </script>
</head>
<body>

</body>
</html>